/*
题目描述
建立一个链表，每个节点包括一个学号信息。将这个链表按逆序排列并输出，即将链表头作为链尾，链表尾作为链头。

输入
第一行有一个整数n，表示链表中的节点个数。保证n不超过100。
之后的n行每行有1个整数，表示每个节点对应的学号信息。

输出
输出逆序排列的链表，每行一个整数表示节点的学号信息。
请注意行尾输出换行。
*/
#include <stdio.h>
#include <stdlib.h>

typedef struct student
{
    int id;
    struct student *next;
} Student;

Student *creatNode(int id)
{
    Student *newNode = (Student *)malloc(sizeof(Student));
    newNode->id = id;
    newNode->next = NULL;
    return newNode;
}

Student *buildList(int n)
{
    int id;
    scanf("%d", &id);
    Student *head = creatNode(id);
    Student *current = head;
    for (int i = 1; i < n; i++)
    {
        int newId;
        scanf("%d", &newId);
        Student *newNode = creatNode(newId);
        current->next = newNode;
        current = newNode;
    }
    return head;
}

Student *reverseList(Student *List)
{
    Student *prev = NULL;
    Student *curr = List;
    Student *temp = curr->next;
    while (temp != NULL)
    {
        curr->next = prev;
        prev = curr;
        curr = temp;
        temp = temp->next;
    }
    curr->next = prev;
    return curr;
}

void printList(Student *List)
{
    Student *current = List;
    while (current != NULL)
    {
        printf("%d\n", current->id);
        current = current->next;
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    Student *List = buildList(n);
    List = reverseList(List);
    printList(List);
}